//
//  SMMainTabbarController.m
//  ShoppingMall
//
//  Created by Demon on 2018/3/21.
//  Copyright © 2018年 Demon. All rights reserved.
//

#import "SMMainTabbarController.h"
#import "SMBaseNavigationController.h"
#import "SMBaseViewController.h"
#import "SMMineViewController.h"

#import "SMLoginViewController.h"

@interface SMMainTabbarController ()<UITabBarControllerDelegate>

@end

@implementation SMMainTabbarController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.delegate = self;
}

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
    UIViewController *vc = [(SMBaseNavigationController *)viewController topViewController];
    if ([vc isKindOfClass:[SMMineViewController class]]) {
        if (login_status()) {
            return YES;
        } else {
            [self presentViewController:[[SMBaseNavigationController alloc] initWithRootViewController:MainStoryBoardVC([SMLoginViewController className])] animated:YES completion:nil];
            return NO;
        }
    }
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end

